Reworked codebase based on modifications from the tutorial version of this code.