Refactored, added notes, pulled magic numbers to globals