Refactored and added class structure for message functionality

Until I speak to Malka I have just coped someone elses structure from
class