Minor bug fixes and some comments added