Implemented rudimentary refinement using only numpy and scipy.