Final Fixes and Code clean up. Moved to a package