Made small refactorings and fixed typos.