Some code cleanup, while working on Library concurency refactoring.

Thanks to Daniel for preparing this patch!