Fix to force session flushes every now and then
Improved scripts