rebuild
better parsing of refs