More stuff

Don't allow to send message when offline. Cleanup. Style fixes.
Reorganize stuff. Make code more readable in the end.