Bug fixes. All the bugs discovered during this and the last commit is recorded in the "issue" section of github page.