Small fixes. Refactoring.