Compound conditions

Thought there has only been limited testing, it should be enough to introduce into the main branch. Changes are limited in scope and there is little room for serious bugs.