Mix of some cleanup and changes to support audit hook implementation