fix php5 notices, strict warnings and code formatting