integrate fixes from https://github.com/dan-v/mint-bitcoin-sync, thanks dan-v