P7, P160: Simplified Java solution.
P166: Reformatted whitespace.
LibraryTest: Added partial test suite for Library.
Library: Added function comments, reordered functions, tweaked logic and error-handling.