fixed many bugs but still has problems when running testfiles 33, 34