Made some structural changes in the code.