minor refactorings to input, speed