Import some fixes from "classicdb" thanks all authors

Signed-off-by: Salja <salja8840@gmail.com>