Pre Maya skype meeting
a bunch of fixes: fixed threading, state machine in main loop, etc