Clean-up

Cleaned up the code a bit.
Commented the code.