repl stage and some cleaning