Fixed gateway parsing for v4 and v6: moved IP parsing from tmp string in another if block, added debug comments, removed redundant variable.