Reorganized to support tests