Add support for ~ and fix a backspace bug.