remove debugging output and optimize code according to analyzer's suggestions