replaced really lame A/V sync code with hopefully working and cleaner code