refactoring and fixes for go1.2