code cleanup for issue #224 and #225