incorporated Frank's improvements from the profiler and smaller changes