Fix for issue #41 and #45