set correct type on many variables, fix a lot of dangerous cast, remove global...
set correct type on many variables, fix a lot of dangerous cast, remove global vars that are likely race conditions in QPSK
set correct type on many variables, fix a lot of dangerous cast, remove global vars that are likely race conditions in QPSK