Various fixes about trading function.