Function for sending messages and commands to the backend. Various other things too.