Define undefined variables

Small fixes. Some errors regarding undefined method / undefined variable.