updated template; code cleanup/commenting