fixed mem errors, added timing