Added 'dirty' flag, which gives us a ~20% speed-up