Cleaned unused code in RM, added documentation