Refactor functionality shared between db & Blbg