Clean up code; fix IE events