fix for reference errors

This fixes issue #2. It looks like previously there were some global functions that live in difference places now.