Fixed the freezing bug.