Improve code quality - weaken types and remove some unused code

Fix a few things the intellij inspection found