Add interactive console and support for piping. Fix segmentation fault.