fixed bugs found by mani