Fix #301 by checking for valid keys.

Have also added a default value for the session 'valid_keys'
variable
Optimize #291, fixing #290 when creating groups.
Version bump