Code Clean Up, and minor bugs fixed.
Added new class to separate code.