Improve parsing and printing of subnets

This pull request contains various improvements to `str2net()` and `net2str()` functions. It fixes some problems with `str2net()` and makes the output of `net2str()` more concise.

If you'd like to test the changes, commit 350c8009d36f2f92408737bef107eac74898f991 contains some throwaway test code.