Consilidated code into rsalib