Logic cleanup for REPL
Merge pull request #725 from david-christiansen/cleanup-repl-invoke

Logic cleanup for REPL