Function arguments working, class fields not (and causing crashes)