lib/structure.js now using named functions to assist debugging