fix deadlock causing sx history to hang.
Merge branch 'spesmilo/master', Conflicts: balance.cpp, history.cpp