Checking in a mess that I need to cleanup.
Updates in conversion from mongo to sql