merged polling and streaming handlers to one, some refactoring.