Added some commenting for next steps, made event emitting/handling functions more generic to aid in writing JSON object to DB in lieu of writing seperate documents for each data parameter