Fix random issues and add more command line options