More code refactoring for more modularity.