Cleaning up a lot of code