Fixes and refactorings

* Some fixes (#45, travis build)
* Some refactoring

This time to the correct branch