Db layout

change DB layout with separate `available_data` fields for efficient queries (+ some cleanup)
fixes #1 
works towards #7 , #10 , #9