Added some buffer-related code, not finished