Stability improvements, new parameters

Added autowrite to modio_push which, when true (by default) will set the
write timer. If this is false, the file must be written and closed
somehow either with forcewrite or by manually calling the write
function.

Improved the way new sessions are registered. It now uses up empty slots
correctly.

Made the script exit fix conditionally compiled.

Added many validity checks and improved debug prints throughout the
script.