Fixed more stupid things with sqlite and actually tested also