Move the temp_rc type to layers and fix some double-borrow issues