The logic can also probably be simplified a lot now that boolean operations can be done between object libraries.