UI code plus some small fixes