Cleanup and code analysis