Split server code into several pieces, tidied it up a bit.
Also added operator.js (I think I'll need it at some point), but it's not used anywhere yet.