[Code] Fixed median filter and frequency counter