enhance contribution counting accuracy

add some table joins to avoid counting dead contributions

issue #253