Ton of refactoring

Signed-off-by: THE DINJ <thedinj@yahoo.com>