added buffer and buffer_static state save and restore