factor out handle_msg and statedict to own files. Also, dropdown