Fixes #6, #10, #12, #13, #14