Fix outofbounds of get_errmsg() and use it in cast functions
Fix typo in basic_operation.hpp