Some code cleanup, syntax corrections, typical new-to-php corrections