Php log error fix436

@willmot R/M please. This PR includes the error log fix and some code reformatting.