fixed a number of issues with reflection code