Changed to boost shared_ptr for vs2008 compatibility. Fixed some problems with events.