Fixes bunch of PHP 5.4 strict notices. Not fully tested!

Small changes that should solve PHP 5.4 strict notices. Please test code before merging.