Add nonce for security.
Introduce fatal result codes. Remove unused return code 'result'.