Looks like we are writing outside the buffer

This fixes #2