Some refactoring and tests added.