fix id handling and remove command

Ensure that anything we are going to need a foreign key for is assigned
an id before we set up the relationship.

Fix the remove command to delete data correctly after the add code was
refactored earlier.
add grep command
Order grep output