cleaned code up a bit, use a coding style more in line with modern php projects