Refactored code to improve some variable and function naming, and completely changed how buffers are handled