Added ability to write keys. Fixed problem with tokens in another layer.