Added lots of fixes suggested by reviewers