refactor, merged app and app delegate, fixed leaks, consolidated code