some fixes and code rewriting for new sequence api