Fix error replies for error handlers
Initial CAP support
Fix CAP handling
remove old code