Cleaned up code and warnings