Added timeout from #20b4488. Modified to be optional

Added timeout from #58 20b4488.