fixed major global referencing problems