Modified some class structures. Fixed bugs.