Refactor the design of conditions
Minor refactor and add documentation for conditions
Merge branch 'refactor-conditions'