Refactor and complete functionality.