Fixes for the DB

part of #51