Refactor

- Improved code and spec
- Added a bunch of comments