add ben's fix for duplicating reference class fields

plus a little bit of additional cleanup

Conflicts:
	src/external.cpp