Update database API usage and performed a bit of code analysis