Scrutinzer fixes

Fixes a few issues and cleans up the code a little