abstract out the find_user step
use correct api for foreign_field
Merge branch 'master' into find_user
a few bug fixes