Cleaned up some buffer code