Basic functionality. Needs refactoring.