sparse weights: bug fixed + Cython typing; also caching the transition weights