Fixed closing bug. High cpu usage bug still remains