Fix #767. Also cleanup some issues with browser navigation.