Move repl to separate file and improve it a bit