Using debug tools and profiling to optimize performance