Save the current file when leaving a directory.

Bug fix for last_cmd and add more info / warning messages.