split types and database into separate files. ditched messages, and made the Sockets layer domain-aware