Refactor rtc implementation