Added patches from issue #49