added comments, buffer test, checked leak