Cleaning up sloppy code