Move error_insertn to .c, add error_new and error_free