remove unused imports and cleanup pattern matching style