Fixes #46, #45, 40