cleaned up some code, calls tick() only when canvas is visible (hopefully this improves performance a bit)