Added error checking code. Updated Rakefile.