Code refactoring and comments. Fix #13