Fix broken accordion widget,

Also clean-up the code some while visiting this file.

closes #5397