code cleanup
added reading of resref