Cleaning up some code and warnings