Fixed various issues in references, closes #75 #100.