Added code to fix issues #321 and #323 from the CPAC issues list