Added first refinement implementation

Still buggy, tests do not pass