Big refactoring to move all display logic to Javascript