bug fixes, memory leaks, timing functions