Merge #152 and make some fixups