window and $ are unused globals. Remove.