Cleanup source code of unused imports and missing annotations (also fixes #365)