Clean up unused code and some reformatting