Refactor to more maintainable state.

- Convert to gem project.
- Refactor to classes in order to simplify complex logic.