Minor changes and code clean-up.

Also moved some things around.