Fix a few bugs, fixes #1867
Small project cleanup:
* add some phpdocs,
* remove unused variables,
* add missing class variables,
* prefer usage of `is_file()` when possible