Moved ui to separate function.
Added flags.