Code clean up. Added comments