moved part of common code to lib
not working message queues added