Add stats support for debug builds
Add lua script