remove expired keys from keys map & minor fixes