Tidy up code per suggestions.