remezord implementation

Rebased remezord implementation as mentioned in #1002