Adding wait-condition notification.

First draft, still have to test on some examples.