Almost complete rewrite

Fixes memleaks, a reported segfault and simplifies the code quite a bit.
It also fixes ipv6 support in the reverse resolve case.
Add tests for ipv6 and error cases
Fix warning when generating the manpage
Shuffle and kill unneeded directory
Fix warning when running automake
Use tabs