Small refactor and change encoding. fixed #126