First draft of the new interactions system

work-in-progress
Second draft of the new interactions system
Implement new replace-* commands
bugfix replacement
Move stack handling to command_line