 		.set("messageEncoding")
 		.set("author")
 		.set("committer")
-	@tree = (cb) =>
-		@repository.tree obj.tree, cb
-	return @
+	return @
+Commit.prototype.tree = (cb) ->
+	@repository.tree @treeId, cb
 
 Gitteh.Tree = Tree = (@repository, obj) ->
 	obj._entries = obj.entries

			return o
	}

Signature = (obj) ->
	immutable(@, obj)
		.set("name")
		.set("email")

	immutable(@, {fetchSpec, pushSpec})
		.set("fetchSpec")
		.set("pushSpec")
	return @

Remote.prototype.connect = ->
	_priv = getPrivate @
	[dir, cb] = args
		dir: type: "remoteDir"
		cb: type: "function"
	dir = if dir is "push" then bindings.GIT_DIR_PUSH else bindings.GIT_DIR_FETCH
	_priv.native.connect dir, wrapCallback cb, (refs) =>
		refNames = Object.keys refs

		# Determine symref for HEAD.
		headOid = refs["HEAD"]
		for ref, oid of refs
			continue if ref is "HEAD"
			if oid is headOid
				headRef = fetchSpec.transformTo ref
				immutable(@, {headRef}).set "headRef", "HEAD"
				break

		immutable(@, {refNames}).set "refNames", "refs"
		_priv.connected = true
		cb()
Remote.prototype.fetch = ->
	_priv = getPrivate @
	throw new Error "Remote isn't connected." if not connected
	[progressCb, cb] = args
		progressCb: type: "function"
		cb: type: "function"

	updateTimer = null
	update = =>
		{bytes, total, done} = _priv.native.stats
		progressCb bytes, total, done
		updateTimer = setTimeout update, 500
	setTimeout update, 500

	_priv.native.download (err) =>
		clearTimeout updateTimer
		return cb err if err?
		_priv.native.updateTips wrapCallback cb, =>
			cb()

Gitteh.Index = Index = (nativeIndex) ->

Gitteh.Repository = Repository = (nativeRepo) ->
	if nativeRepo not instanceof NativeRepository
		throw new Error "Don't construct me, see gitteh.(open|init)Repository"
	_priv = createPrivate @
	_priv.native = nativeRepo

	immutable(@, nativeRepo)
		.set("bare")
