added a couple casts, a closure param type, and a couple @SuppressWarnings to eliminate all the IntelliJ inspection warnings