Fixed missing semicolons
Delete unused variable and if block
Delete unused ttl and timestamp variables
Fix global variable in for loop
Delete unused if block