Buffer cleanups and layer stuff