Cleanup

Small tweaks based on code analysis, IDE warnings, and test runs