Library.java (does the bulk of the work)