Add support for anaytics.
More error checking.