Cleaned up code by moving the random prefix/postfix into do_character()
Cleaned up the failure logic to avoid infinite loops / slow failures. Added more tests. Works in the vast majority of cases, now (failures still happen, but they're increasingly rare)