Merge srm code from project chunming-topcoder. cloc: 125 664 813 5182