typos, dead code removal and minor refactorings