finishing touches

Cleaning up code, fix whitespace, some comments