Update stat.js

Added comments and few enhancements.