WIP! More Piper code

This is under some fairly heavy development so I don't promise everything is coherent.