Clean up unused code and some coding style