added stream size hinting and performed general code cleanup