add caching of columns in $database
Push all metadata calculations in database

Fix #4