Refactored.
Cleaned up error messages slightly, removed -p.
Better handling of qualifiers, other stuff.
Moved some tests around.