Fixes from https://github.com/markfisher/xdzk/pull/8