Debugged the Savitsky-Golay filter. It works as expected now.