Fixes and simplifications from code review