Externalize paths

Subtle formatting and cleaning up of PHP code.