major refactor

More in the style of urlserver.py, makes a bit more sense. But it's
not yet handling messages properly, even though code is better.

Oh well...
basic message handling working again