revamp of run.php to get it working correctly, minor changes to other php scripts