fixed bugs found with grant