Code cleanup and fixes
Code cleanup again