Refactor to remove circular dependencies and use relative imports.