Database reading + minor fixes