Added LOCAL_DEV constant, cleaned up db code