Clean up first part of InitialiseSettings.php

I think it is better to do this in small chunks, to avoid
having to constantly merge in new stuff. I think that is
why I2700c3cfc0a4f43077a0df78d65235f1ac48bffa has not gone
anywhere.

I have double-checked this to ensure nothing
has actually been changed. Code has been moved around but
not actually modified (diff engines, of course, hate this
kind of stuff).

Related to bug 29902.

Change-Id: I23e04f26a780aaa0e0692616c732d7b160dcccb3