Small bug fixes and emptying functionality

I don't have time to write failing tests. The changes are minor and you'll probably find them useful. Thanks.