Fix timeout and add support for setting timeout from command line