Some improvements

* Parameters added + Restructuration
* Some PHP code style improvements

Just syntax tested (from php -l). Be aware and careful about it.