Update tickscrub

Ok so this script is only getting more complex as time goes on, and it's sorely in need of some basic commenting since really, really inscrutable at present, but it produces output that can go straight into a MariaDB without further fuss, so it's got that going for it