Improved run.php; todo: fix isLegacy function