Bug-fix: if-else chain was broken.
Robustness to no library files and empty dictionaries.