Some code cleaning + simplification