Fixed null reference exceptions when deleting a command class