fixed client logic and db lookup, renames and refactors