Fixed #2, #4. Refactoring.