Fixed history queue handling.
Minor template mods & cleanup.