code review part 4

Changes are:

* fix issues with exclude feature
* output now does not only print pages, but also directories
* some refactorings (inlining only once called functions) and coding style changes