multiple fixes and cleanup and polishing