Fix bug when running from commandline.