Refactoring and reformatting.

Removed a bunch of commented commands, added database existence
verifications for Server 2003, and generally moved code blocks around to
create a more logical flow.
Tested all possible database locations

Made a few formatting changes, but confirmed logic looks ok.