Refactoring and multiprocessing