added metadata
refactored stream handling interface
some basic tests and corrected bug on metadata
fixed #7