DB state functions. Will document more later