More coding fixes - refactor hell