Add a bytebuffer API

Move main into a separate file