Fixed weird freezing bug