Just ported over some stuff [2]