Fixed several 'Undefined property' and 'Undefined variable' errors