Fixed typo
Some refactoring and some additional comments