Progress on #130, it mainly works