some mvs
some rms
minor changes
dels global vars
cosmetic changes
switching to refs
some oop
minor changes
and more