Comments and a fix for layer freeing.

This has some comments and a small (probably unrelated) uninitialized variable fix resulting from issue #1414.