Took lots of mess out of app delegate