fixes several problems with transformation code