Cleaned up code and comments