Implement Palette, LibraryManager and did some general refactoring.