No functional changes. Only a bit of code cleanup and refactoring. Signed-off-by: Carlo Caione <ccaione@baylibre.com>