I've heard that the "Thou shalt not kill" commandment actually means something more along the line of "Thou shalt not kill anyone who is one of us(Israeli tribes at the time)". This is why the orders to kill everyone who wasn't one of them aren't considered contradictory. Though that does remove one of the few good things in the Old Testament.
@Her3tik's picture- Is that supposed to be for or against the electric fence thing?