Fixes #452 submitted by @jpnurmi

Also redesigns some internal workings of client capacities to put them
in their own struct for easier management.