I re-organized the code to make it more uniform and moved code around to achieve the desired results.
This patch was tested on a Fedora 20 machine via the shell script called pki/base/scripts/pkiclihelp.