Fixed potential initialization race conditions. Fixed issue with program crashing if 'error' is not listened to by user.  Made ms argument optional
made example file simpler