Increased max allowed kern size from 1000 to 10000
Added median filter