refactored code for locating refs and additional properties

still needs some work to account for potential use cases.
stable for now.