lots of bug fixes + rms impl