Profiling: refactored the way that profilereports builds up a database