Fixes #17, #18 and #19