handler refactor, more cythonizing