Add support for segments. Add support for filtered elements. Various smaller improvements and bugfixes.