register safety, sys_curfile, other small fixes