Fixes #11, #20, #21