some code cleanup and disp statements added for debugging