Trying to fix db bugs