massive code-deduplication/refactoring in filter.cpp; Makefile.pre added with additional clang diagnostic flags