Completed refactoring of datasource. Initial tests pass.