Fix and clean code