handle references error + some deps improvements