refactor and add namespaces

Signed-off-by: flash-square <david.guillemin@gmail.com>