Another attempt at improving queue management

Check and alter queue state in both the parser and the saveCB, also
improve the file and program ending.