Refactor #2

This builds on top of #124.