Re-arranged some of the functions to ensure coherance