Fix some variable naming and add some extra logging