Batched writes

It's in pretty raw form right now, all my tinkering is still in there, so I wouldn't just merge as is.