Restructured code. Added new classes