Added some debug information. Fixed minor issues in key management.
Added flash storage for nonce data.