Track dirty state of buffers

Signed-off-by: Casey Dahlin <casey.dahlin@gmail.com>