Fixed some bugs in the exchange implementation