Cleaning up a bunch of warnings and removing dead code