initial code, tested on a single library in both separate and common modes.