CE-311 Refactoring messages plus giet rid of unused global vars