cleaned up processing code (removed useless statemachine); fixed a very unlikely racecondition