Organize into packages

* Remove encoding
* Organize into packages
* Refactoring
* Bug fixes