Fuck bit twiddling, this is probably riffled with bugs. Needs some
serious testing...