Code refactored to clean it and avoid API breaks.