tighten types, improve error printing, and fix an error in cdata
int64 to int to solve 32/64 bit interop