fixed prepared statement creation order, refs #563