Refactor to remove duplicate code
Add full command history, fix line not reliably cleared when echoing current command to console