Refactor rc

@rytaft Here are the changes for extract , clean up and some debugging.