Fix null pointer with commands, improve external data handling