Bugfixes on some undefined variables