refactor
add comments, remove pthread_once (we lock anyway)