Removed debugging prints, re-added error handler, removed unneeded variables