move non-db code to mapper

Prepare to separate DB backend for luna