Fixed a few typos. Added some security checks.