Refactored the source code and unit tests to reflect recent changes.