Cleaned Code. Fixed a few bugs.