Fixed a issue during mediawiki upgrades preventing you from running upgrade.php
Also fixed some minor issues with coding style