Added listeners after the "dispatch" event, allowing for the navigation to be displayed anywhere.
Added a fix if magic_quotes are enabled.