fixed avmode and did some debugging and testing