Fix the retrieval of command line args
Simplify database-related code