Added definitions of functions, missing variables and constants.