#6: fixed some undefined vars and bad function args