Switched to buffer per attribute scheme.

Would be awesome if someone could test this before merging. I wasn't able to get the example compiling due to multiple unrelated issues.

This is mostly a refactor. We'd see a bigger difference between added and removed lines if I didn't add assertions and split some long lines into multiple ones. Also, a bit of comments.

Closes #44 

cc @bvssvni