Cleaned up code and removed warnings