Should probably do some more refactoring.