added npe checks to getCounter and getCounterForInterval