Use helper functions for typemap rules
Change code style
Change integer type
Add vertical spacing
Refactor length check