Added mem leak check and time measurements.