Refactor to define each module as a library.