Improve robustness of typemaps