Clean code and fix bugs