Some code cleanup after helpful tips from Jared
Fixed failing integration test