Almost all UI code ported