Fix undef var and auto mapping