Fixed a problem with function freezing.