Refactors bufferpool Get and Write

Extracted similar code between Get and Write in bufferpool.
Refactors bufferpool Get to GetRecord. Made function more readable.
Removed the byte array parameter.
Refactors bufferpool Write to WriteRecord and makes it more readable.