Initial commit with tl and rtl
fixed race condition and error check for init function