Tweaked so works in production mode