turns out that shared_from_this() can not be called from the constructor, so we made a special attach() function to postpone object initialization