Refactor

- cleanup headers
- move code to cpp files
- add comments
- add missing files