cleanup and testing of references