Updated crappy non-working code. Slightly closer to figuring out what's
going on though.