Implemented automatic reconnecting

Closes #104.
Also thanks to MrCustomizer for the great work.