Clean up some code and remove warnings