Moved most display code into Javascript