Greatly improved speed by caching Marked classes

Speed was improved at least by an order of magnitude (from ≈5.4 s to ≈0.5 s)