refactoring, redesigned connection/message handling