Seperated main class from streambuf implementation.