Fixed some ordering bugs