More progress, adding ercal's code now.