Lots of cleanup and refactoring for the language support