Adding further changes. Fixed a few bugs