Devel

Fixes #15 and #30, partially fixes #21.