Application profiling

Fix leaks found after profiling