More code cleanup of main module.