Formatting of code; add some controls