Fixed when() API. Reorganized.

Stable Version 0.5.1.