Various fixes in the EE to make sure that it builds with DEBUG enabled
Stupid refactoring to make neworder's SQLStmts more readable...