Buffer logging, cleanup patch