start of ugly code fixup