Fixed CODE_DIR autodetection to use the found dir.