Clean and fix bugs