(WIP) Server boilerplate

This is based on the deploy-network branch, so it's got some other stuff that isn't quite merged in yet; the last commit is the relevant part. This was bugging me.

I probably need to add a few comments about the implementation; the code is a bit tricky.