Fix to issue #25 and #26 and also fix layout when history does not exist.