Added edge detection, improved keybindings, fixed restarting issue