Pasting a fairly complicated function without providing the data structure definition on which it operates would not help anyone in aiding you. What i would suggest is that you set a breakpoint within the function implementation and carefully step through it whilst keeping a watch on the avlnode to see what happens after each and every step.
NB: a faster way to help you will be to get Boost(or any C++ test package) and write a couple of test cases to ensure that each and every function you will eventually be using on the tree meets the desired functionality. It might be that your remove function is correct, but another function involved in building the tree messes up the internal pointer assignments.