diff --git a/apa b/apa
index d640fb46a508f4902ace265ecb7844050018ac8f..34eb480c5ac0a65bebdda756174ec18cd1d1b3c3 100755
--- a/apa
+++ b/apa
@@ -163,11 +163,14 @@ class Importer:
         BAD = None
         try:
             code = compile(src, "%s/%s" % (self.path, filename), 'exec')
-            exec code in mod.__dict__
-        except exceptions.SystemExit, e:
+            if sys.version_info < (3,):
+                exec("exec code in mod.__dict__")
+            else:
+                exec(code, mod.__dict__)
+        except SystemExit as e:
             # Silently propagate exit
             raise e
-        except Exception, e:
+        except Exception as e:
             # Silently propagate other exceptions as well
             BAD = sys.exc_info()
             raise e
@@ -204,18 +207,17 @@ def extract(dest='.'):
         f = file(filepath, 'w')
         f.write(c)
         f.close()
-        os.chmod(filepath, 0755)
+        os.chmod(filepath, 0o755)
     
 if __name__ == '__main__':
     import sys
     importer = Importer(code)
     sys.path_hooks.append(importer)
-    import exceptions
     import imp
     try:
         # This will start actual execution
         importer.load_module("__main__")
-    except exceptions.SystemExit, e:
+    except SystemExit as e:
         raise e
     except:
         if BAD: