Reorganized into potential classes and public functions.