I am quite sure your rough idle problem is due to your idle control valve. The inboard computer can pick up an ICV problem when it is really not functioning at all. When it is functioning even badly the car wont pick it up thus causing the check engine light to flicker on and off