More assorted changes

A few minor logic changes, some internationalization fixes, some whitespace and code style tweaks to bring it into line with WP Code Style guidelines.

Also two minor bugfixes.