Many improvements, fixes and implementations for db