Refactored code to be more analogous with the Minecraft source