Fix syntax errors and some other miscellaneous issues