lots of cleanup and warnings removal