GavinE fixed issues with previous refactor