Updated reference resolution

--added better documentation
--added better error checking
--made resolution procdure better + not broken