separated application from library, added comments, and fixed bug where template parent node was lost on promised values