Fixes #48, #152.