Improved autosave semantics

Moved most of the necessary checks into the autosave() function itself.