Better LayerBuffer management

Prevents unnecessary copying of buffers, and implements buffer recycling.