Lots of changes to allow for proper analytics functionality and profiling