[BUGFIX] Prevent crashes in find_common_factor()