moved client files to client folder
moved code to callback
added publishing of events