Huge commit now that it works. Also, I flattened the git history