Async and fixed priority and on switch

I have made the condition and consequence functions asynchronous so that they can make database and other IO calls. 
I have also fixed the priority and on switch.