Revert "Revert "Code cleanup.""

This reverts commit 52b2e9fb6a8bf3514e9bd53d41b20f38dd064eae.