Cleaned up DB functionality