Tidied and minor cleanup