fixed various problems with the previous commit


Contributor: Tushar Narayan