Fixed some bugs

Further bug fixing done