Fix bugs in launcher script