Fixed bug that caused headache in functions.