Added security comments and getNonce functions