Move intersection calculation from app to library