Cleaning up a few bugs