Generalize WindowModel to allow custom filters

Also add a debugging flag for tracing