Minor tweaks and tidying of the key manager