Fix all kinds of code smells