adding io_wait and button_wait options and split threads for io and
buttons