Fixed syntax and logic errors in functions and function calls.