improve session and persistent undo to create directory if it not exists