In general move variable declaration closer to use
get rid of call to A api and replace with W api equivalent
build as C++ (interim commit, does not compile)
Fix the build, and have textevents support C++ inclusion