Modularize more functionality