Fix issue #2 and add patch for issue #328