Fixed some bugs. TODO: fix double handling of double orders