Added time measurement to various places.