Use new exceptions.
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index b25615933..1f1dcae 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -95,7 +95,7 @@
 #endif
 	f->f_fp = fopen(name, mode);
 	if (f->f_fp == NULL) {
-		err_errno(RuntimeError);
+		err_errno(IOError);
 		DECREF(f);
 		return NULL;
 	}
@@ -166,7 +166,7 @@
 	if (sts == EOF) {
 		if (errno == 0)
 			errno = EIO;
-		return err_errno(RuntimeError);
+		return err_errno(IOError);
 	}
 	if (sts != 0)
 		return newintobject((long)sts);
@@ -198,7 +198,7 @@
 	if (fseek(f->f_fp, offset, (int)whence) != 0) {
 		if (errno == 0)
 			errno = EIO;
-		return err_errno(RuntimeError);
+		return err_errno(IOError);
 	}
 	INCREF(None);
 	return None;
@@ -219,7 +219,7 @@
 	if (offset == -1L) {
 		if (errno == 0)
 			errno = EIO;
-		return err_errno(RuntimeError);
+		return err_errno(IOError);
 	}
 	return newintobject(offset);
 }
@@ -237,7 +237,7 @@
 	if (fflush(f->f_fp) != 0) {
 		if (errno == 0)
 			errno = EIO;
-		return err_errno(RuntimeError);
+		return err_errno(IOError);
 	}
 	INCREF(None);
 	return None;
@@ -441,7 +441,6 @@
 	object *args;
 {
 	int n, n2;
-	char *s;
 	if (f->f_fp == NULL) {
 		err_badarg();
 		return NULL;
@@ -452,20 +451,11 @@
 	}
 	f->f_softspace = 0;
 	errno = 0;
-	n = getstringsize(args);
-	s = getstringvalue(args);
-	if (n > BUFSIZ) {
-		fflush(f->f_fp);
-		n2 = write(fileno(f->f_fp), s, n);
-		fflush(f->f_fp);
-	}
-	else {
-		n2 = fwrite(s, 1, n, f->f_fp);
-	}
+	n2 = fwrite(getstringvalue(args), 1, n = getstringsize(args), f->f_fp);
 	if (n2 != n) {
 		if (errno == 0)
 			errno = EIO;
-		err_errno(RuntimeError);
+		err_errno(IOError);
 		return NULL;
 	}
 	INCREF(None);
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 18bdbca..2e2b9a2 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -543,7 +543,7 @@
 		if (cmpobject(self->ob_item[i], args) == 0)
 			return newintobject(i);
 	}
-	err_setstr(RuntimeError, "list.index(x): x not in list");
+	err_setstr(ValueError, "list.index(x): x not in list");
 	return NULL;
 }
 
@@ -586,7 +586,7 @@
 		}
 			
 	}
-	err_setstr(RuntimeError, "list.remove(x): x not in list");
+	err_setstr(ValueError, "list.remove(x): x not in list");
 	return NULL;
 }
 
diff --git a/Objects/longobject.c b/Objects/longobject.c
index fb5d241..37f2f35 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -168,7 +168,7 @@
 		prev = x;
 		x = (x << SHIFT) + v->ob_digit[i];
 		if ((x >> SHIFT) != prev) {
-			err_setstr(RuntimeError,
+			err_setstr(ValueError,
 				"long int too long to convert");
 			return -1;
 		}
@@ -422,7 +422,7 @@
 	if (size_b == 0) {
 		if (prem != NULL)
 			*prem = NULL;
-		err_setstr(RuntimeError, "long division by zero");
+		err_setstr(ZeroDivisionError, "long division or remainder");
 		return NULL;
 	}
 	if (size_a < size_b ||
@@ -938,7 +938,7 @@
 	if (size_b == ~0)
 		size_b = 0;
 	else if (size_b < 0) {
-		err_setstr(RuntimeError, "long integer to the negative power");
+		err_setstr(ValueError, "long integer to the negative power");
 		return NULL;
 	}
 
@@ -1054,11 +1054,11 @@
 	if (shiftby == -1L && err_occurred())
 		return NULL;
 	if (shiftby < 0) {
-		err_setstr(RuntimeError, "negative shift count");
+		err_setstr(ValueError, "negative shift count");
 		return NULL;
 	}
 	if (shiftby > MASK) {
-		err_setstr(RuntimeError, "outrageous shift count");
+		err_setstr(ValueError, "outrageous shift count");
 		return NULL;
 	}
 	wordshift = shiftby / SHIFT;
@@ -1105,11 +1105,11 @@
 	if (shiftby == -1L && err_occurred())
 		return NULL;
 	if (shiftby < 0) {
-		err_setstr(RuntimeError, "negative shift count");
+		err_setstr(ValueError, "negative shift count");
 		return NULL;
 	}
 	if (shiftby > MASK) {
-		err_setstr(RuntimeError, "outrageous shift count");
+		err_setstr(ValueError, "outrageous shift count");
 		return NULL;
 	}
 	if (shiftby % SHIFT == 0) {
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index ffc8e74..1104986 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -118,7 +118,7 @@
 	}
 	res = dictlookup(m->md_dict, name);
 	if (res == NULL)
-		err_setstr(NameError, name);
+		err_setstr(AttributeError, name);
 	else
 		INCREF(res);
 	return res;
@@ -131,7 +131,7 @@
 	object *v;
 {
 	if (strcmp(name, "__dict__") == 0 || strcmp(name, "__name__") == 0) {
-		err_setstr(NameError, "can't assign to reserved member name");
+		err_setstr(TypeError, "can't assign to reserved member name");
 		return -1;
 	}
 	if (v == NULL)