first connecting skeleton
added internal processing of connection events
pulled out script