Cleanup

Cleaned up code for better understanding.