Some small changes to the save_buffer function