Added code to manage session and clean messages after usage.
Changed messages and errors to be stored as arrays instead of strings.