fixes #1819 - moved some var definitions to please IE