fix subscription server  bug introduced when porting to async, add support for event in server, reorganization

lots of changes. I should have tested more but there are so many changes it is better to merge otherwise it will be hard to merge
Do we need this commented block?