Various fixes

Unused imports, calls to undefined functions/vars, etc.