Added debug logging
Added header output / trim on parameters