Fixes from code review on #1161