15 minutes just saved you 15% on file size

I refactored a ton of stuff here, it was really quite ugly and non-DRY. It still is in some places but whatever, this isn't even my code.