Refactor and clean up
@DouweM @lmcandrew feel free to review if you want. This is a step before #6 (closed) and #7 (closed), which in turn come before #4 (closed)
@DouweM @lmcandrew feel free to review if you want. This is a step before #6 (closed) and #7 (closed), which in turn come before #4 (closed)