Fixes #59, #50, #44 and #32