Library concurency refactoring

This are some code clean ups, for a clean merge against master