Full fix for issue #1