Complete rewrite, CnCNet 5a

Also completely untested.