cleanup

- cleaned up some code
- added comments