Some cleanup to make the code *slightly* more sane