More code tidy ups and improved Fix #575 to prevent regression
Fix regression causing scenario tests fail