Assertions

I moved the definition of `struct buffer` out of buffer.h into the implementation file, so that its internal management is focussed into one file. All macros have been turned into functions. The change did not measurably affect performance.