a few minor refactorings from luketower's feedback