added indexof(), and moved buffer_indexof() code into it