Added profiler. Small bug fixes.