Enabled optional debug mode if NODE_ENV is set
Improved debug logging by making it optional