Updated files and refactored slightly.