Tidy-up, removing spaces at end of lines and debugging print statements