Event handling implemented. Examples with time handling added