Added joein3d's changes