Cleanups and code refactoring.

Signed-off-by: Piment Noir Task Force <elecdev@piment-noir.org>