Refactored codebase

* Fixed #33