Added 'dirty' counter to implement API caching