General code clean and tidy