Some re-arranging of some code to make it more consistent