Initial commit, fixes #17 and #19