Fixed handling of caps, plus general updates.