added simple profiler and major stability work on sort