Refactored. Split up the large file.