Improved PRODUCTION detection.
Fix lint warnings.
Optimize ndb queries.