Typos
Some refactoring