WIP! More Piper code

This is under some fairly heavy development so I don't promise everything is coherent.
probably connection errors or some kind of problems with the DB when this is implemented, yep