core ported - needs cleanup