Fixed compatibility issues with older PHP5 versions
Some formatting improvements