more rewrites, cleaned up the mediastream object and added a buffer object