Cleaned up code and updated code comments