Added exception on connection and refactored to be PSR-4 compliant