fix #27; fix and improve QUIT handling, other improvements