Refactor set_mark() and open_buffers()