Remove unused vars
Don't calculate PUBLIC_IP unless necessary
Reorder some vars for more readability