Storing events to SQL DB and some style improvements