Code cleaning and security enhancement for setup