Added misc buffer cleanup functions