reimplemented buffers using a class so it (hopefully) works