Basic architectural changes

Fixed up some basic architecture. Added buffering support (I don't know
why I did this first, but it's there so...)