Small enhancements

Fixing/enhancing some issues found by IntelliJ IDEA