added JSON serialization, refactored AbstractConnector to stop leaking memory