Fix coding standards issues

This fixes coding standards issues and one minor potential bug.