Fix security issue due to multiple accesses. Version bump to 3.1