beginning refactor to avoid catastrophic future failures. bug has been found and (hopefully) squashed. i am immortal.