cythonized watershed_util