Refactor process_manager