diff --git a/dulwich/misc.py b/dulwich/misc.py
index 0e0a2d20deed9552df41153fde587a8145b1c64d_ZHVsd2ljaC9taXNjLnB5..8f5fddaf002abe664feb31b53e979692aacabf97_ZHVsd2ljaC9taXNjLnB5 100644
--- a/dulwich/misc.py
+++ b/dulwich/misc.py
@@ -20,9 +20,15 @@
 These utilities can all be deleted when dulwich decides it wants to stop
 support for python 2.4.
 """
+
+from mercurial import demandimport
+import __builtin__
+orig_import = __builtin__.__import__
+demandimport.disable()
+
 try:
     import hashlib
 except ImportError:
     import sha
 import struct
 
@@ -23,9 +29,10 @@
 try:
     import hashlib
 except ImportError:
     import sha
 import struct
 
+__builtin__.__import__ = orig_import
 
 class defaultdict(dict):
     """A python 2.4 equivalent of collections.defaultdict."""
diff --git a/dulwich/objects.py b/dulwich/objects.py
index 0e0a2d20deed9552df41153fde587a8145b1c64d_ZHVsd2ljaC9vYmplY3RzLnB5..8f5fddaf002abe664feb31b53e979692aacabf97_ZHVsd2ljaC9vYmplY3RzLnB5 100644
--- a/dulwich/objects.py
+++ b/dulwich/objects.py
@@ -467,7 +467,7 @@
             assert text[count] == ' ', "Invalid commit object, " \
                  "author information must be followed by space not %s" % text[count]
             count += 1
-            self._author_time = int(text[count:count+10])
+            self._author_time = int(text[count:].split(" ", 1)[0])
             while text[count] != ' ':
                 count += 1
             self._author_timezone = int(text[count:count+6])
diff --git a/dulwich/pack.py b/dulwich/pack.py
index 0e0a2d20deed9552df41153fde587a8145b1c64d_ZHVsd2ljaC9wYWNrLnB5..8f5fddaf002abe664feb31b53e979692aacabf97_ZHVsd2ljaC9wYWNrLnB5 100644
--- a/dulwich/pack.py
+++ b/dulwich/pack.py
@@ -30,6 +30,11 @@
 a pointer in to the corresponding packfile.
 """
 
+from mercurial import demandimport
+import __builtin__
+orig_import = __builtin__.__import__
+demandimport.disable()
+
 try:
     from collections import defaultdict
 except ImportError:
@@ -61,6 +66,8 @@
     )
 from misc import make_sha
 
+__builtin__.__import__ = orig_import
+
 supports_mmap_offset = (sys.version_info[0] >= 3 or
         (sys.version_info[0] == 2 and sys.version_info[1] >= 6))
 
@@ -107,9 +114,14 @@
     :param access: Access mechanism.
     :return: MMAP'd area.
     """
-    mem = mmap.mmap(f.fileno(), size+offset, access=access)
-    return mem, offset
-
+    print f, offset, size
+    if supports_mmap_offset:
+        mem = mmap.mmap(f.fileno(), size + offset % mmap.PAGESIZE, access=access,
+                offset=offset / mmap.PAGESIZE * mmap.PAGESIZE)
+        return mem, offset % mmap.PAGESIZE
+    else:
+        mem = mmap.mmap(f.fileno(), size+offset, access=access)
+        return mem, offset
 
 def load_pack_index(filename):
     f = open(filename, 'r')
@@ -451,6 +463,5 @@
         """Calculate the checksum for this pack."""
         map, map_offset = simple_mmap(self._file, 0, self._size - 20)
         try:
-            return make_sha(map[map_offset:self._size-20]).digest()
-        finally:
+            r = make_sha(map[map_offset:self._size-20]).digest()
             map.close()
@@ -456,4 +467,8 @@
             map.close()
+            return r
+        except:
+            map.close()
+            raise
 
     def resolve_object(self, offset, type, obj, get_ref, get_offset=None):
         """Resolve an object, possibly resolving deltas when necessary.
@@ -500,5 +515,4 @@
                 offset += total_size
                 if progress:
                     progress(i, num)
-        finally:
             map.close()
@@ -504,4 +518,7 @@
             map.close()
+        except:
+            map.close()
+            raise
   
     def iterentries(self, ext_resolve_ref=None, progress=None):
         found = {}