code review changes and a small bugfix