3rd commit. Final version. Better class organization.