Added validation before sending messages to the middleware to prevent wrong user actions. Various bug fixes.
More explicit error messages to know which object raised the error.