Moved common functionality to a shared file for maintainability. Some tweaks and refactoring. Updated run times.