fixed bugs found by rev1