Refactor.
Better error handling.