diff --git a/pyopencl/__init__.py b/pyopencl/__init__.py
index 099af5874ee422ffab1dcbf896b76b75d91fa3f8..716cd4f4f9dfb17247c617d9240bb99372c66562 100644
--- a/pyopencl/__init__.py
+++ b/pyopencl/__init__.py
@@ -232,10 +232,7 @@ class Program(object):
 
                 what = what + "\n(source saved as %s)" % srcfile.name
 
-            code = e.code
-            routine = e.routine
-
-            err = _cl.RuntimeError(routine, code, what)
+            err = _cl.RuntimeError(msg=what, routine=e.routine, code=e.code)
 
         # Python 3.2 outputs the whole list of currently active exceptions
         # This serves to remove one (redundant) level from that nesting.
@@ -415,14 +412,12 @@ def _add_functionality():
         err = None
         try:
             self._build(options=options, devices=devices)
-        except Exception, e:
+        except Error, e:
             what = e.what + "\n\n" + (75*"="+"\n").join(
                     "Build on %s:\n\n%s" % (dev, log)
                     for dev, log in self._get_build_logs())
-            code = e.code
-            routine = e.routine
 
-            err = _cl.RuntimeError(routine, code, what)
+            err = _cl.RuntimeError(msg=what, routine=e.routine, code=e.code)
 
         if err is not None:
             # Python 3.2 outputs the whole list of currently active exceptions
diff --git a/pyopencl/cache.py b/pyopencl/cache.py
index 9971b1e3da62852f2a43d2bdef83098dcfc4e7fe..9a6a2cf6aee63b20f75c2a2242436f34aba3e61c 100644
--- a/pyopencl/cache.py
+++ b/pyopencl/cache.py
@@ -479,7 +479,6 @@ def create_built_program_from_source_cached(ctx, src, options=[], devices=None,
             already_built = False
 
     except Exception, e:
-        raise
         from pyopencl import Error
         if (isinstance(e, Error)
                 and e.code == _cl.status_code.BUILD_PROGRAM_FAILURE):
diff --git a/pyopencl/cffi_cl.py b/pyopencl/cffi_cl.py
index 0f311f640e0ffdb3b7149804375eea0c911ac6a5..456813b2f56fd9b70d3e22f3a8ae33d9dfe9264c 100644
--- a/pyopencl/cffi_cl.py
+++ b/pyopencl/cffi_cl.py
@@ -261,6 +261,7 @@ for type_, d in _constants.iteritems():
 class Error(Exception):
     def __init__(self, msg='', routine='', code=0):
         self.routine = routine
+        assert isinstance(code, int)
         self.code = code
         self.what = msg
         super(Error, self).__init__(msg)
@@ -296,6 +297,7 @@ def _handle_error(error):
         klass = RuntimeError
     else:
         klass = Error
+
     e = klass(routine=_ffi.string(error.routine),
             code=error.code, msg=_ffi.string(error.msg))
     _lib.pyopencl_free_pointer(error.routine)