Changed reset logic and fixed esc bug