Added propper key management code.