Modularize and clean up
Modularize and clean up