large restructuring changes to make more generic for multiple app usage