Implemented error trace generation.
Minor fixes to error generation.