fixed functions names and signatures
merged changes and fixed variable name