Updated based on Myron's code review