simplify startup routine a bit and fix bug related to the -h flag