A few changes:
1. Make all variables local.
2. Handle ngx.timer.at and sock:setkeepalive error
3. Style fixes
4. Pre-allocate space for table