Removed dead code; fixed phpdoc

There is a lot of undeclared properties, I've declared them and added few missing phpdocs. I've also removed dead code.
I wanned to first fix the biggest problems, like missing properties and dead code.
I'm going to prepare another pull, that will have a lot of changes in formating.
My intention was to separate the code changes and style changes as much as possible to provide readable diffs.