Minor Bug fixes
PHP code improvements

Core PHP no longer needs editing. Only variables in head of PHP file