initial pass at a state machine for messages

doesn't really work yet
some updates to test