Refactoring and cleanup

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>