Logic Cleanup and a few improvements ands fixes