Better error checking. Minor bug fix to summary.cpp.