Fixed syntax errors and handled some error checking.

Also got rid of an unnecessary error check.