Clean code and bug fixes