diff --git a/lib/SFTP/SFTPv3.js b/lib/SFTP/SFTPv3.js
index <HASH>..<HASH> 100644
--- a/lib/SFTP/SFTPv3.js
+++ b/lib/SFTP/SFTPv3.js
@@ -8,6 +8,8 @@ var MAX_REQID = Math.pow(2, 32) - 1,
                                  0, 0, 0, 3 /* version */]),
     EMPTY_CALLBACK = function() {};
 
+module.exports = SFTP;
+
 function SFTP(stream) {
   var self = this;
 
@@ -22,8 +24,18 @@ function SFTP(stream) {
   this._field = 'packet_length';
   this._data = { len: 0, type: undefined, subtype: undefined };
 
-  stream.on('data', function(data) {
-    self._parse(data);
+  stream.on('data', function(data, type) {
+    if (!type)
+      self._parse(data);
+  });
+  stream.on('error', function(err) {
+    self.emit('error', err);
+  });
+  stream.on('end', function() {
+    self.emit('end');
+  });
+  stream.on('close', function(had_err) {
+    self.emit('close', had_err);
   });
 }
 inherits(SFTP, EventEmitter);
sftpv3: set module exports and pass on some underlying stream events