Memory leak fix

FIxed memory leaks and URI path issue making many streams not work.