Code cleanup, simplified the interface, make sure uniqueness of Library name, added some checks