fix more various errors
mapping ^C to quit main loop
add toggle flag method