Code cleaning and bug solving