added login/logout messages, unified sendmessage into function, fixed hacking loophole