code cleanup. handleEvent looks much nicer now
minor changes