Refactor the libraryControl plugin