Some tidying and be a bit more defensive.