more ntype codes
cleanup and error handling