Refactoring + some unit tests + Travis CI, couple of bug fixes