Fix bug
Code simplifications