add free for fpo stream and do some refactor