streaming api connection working + some refactoring