Brought all files mostly up to compliance with PHP_Codesniffer. Some more refactoring.