Cleaned up code and completed comments