Add 'log' as wait option and refactor wait mechanism.