Refactroing Code.

Uploading a working copy..