Syntax errors corrected, some style fixes and minor semantics