Updated fix for issues #17, #18 and #23.