ported some stuff