major changes; added functions for extracting errors; fixed a few bugs from the previous version