move swift and abstract code to core