Add check for required flags.

- While at it, also slightly rename them.
Fix database lookup.

- Time values are now returned as time.Time.
- Some other minor fixes in error cases.