fixes bugs present in previous commit
removes leftover debug prints