Added more unit tests, implemented datastream events, fixed bugs.