Fixed numerous bugs, got rid of explicit dependence on foreach which didn't help performance all that much.
Fixed numerous bugs, got rid of explicit dependence on foreach which didn't help performance all that much.