Created by: reyoung
Simplify the implementation in #1452. We could use reflection in Python, not handwriting code which could not be maintained later.