Implemented fixes from code review with Ivan.