Address various problems with source code as suggested by @demobox.