mesolve: minor performance tweaks and code cleanup (use cython expect function instead of python function)