moved more code from app delegate to core data manager