server: Fix layout of terminals resize to contents

Size the terminal to the contents properly, and tweak the margins
a bit. Other minor cleanup.