Update with bug fixes and comments