Fixed bugs passing object by reference, use pointer instead.