Functionality to manage output, exiting/reseting in session and a few other improvements