Code Cleanup, and bug fixes.