Fixed errorhandling.