added more memory management & timing