Add some build code and tidy up