refactoring
py2 support
speedup