WIP of bug 1076706, and card_manager.js is still in a mess