Improved structure, added test file, better output streaming