Fix the handling of subexpressions that are referred to (e.g. in synapses). Still needs proper tests, but closes #228
Add tests for references to subexpressions.