Refactored connection methods.
Added event methods.