Improve unsaved buffers check