Simpler implementation from PR feedback.