Complete refactoring of the tool

Signed-off-by: Andrew 'Necromant' Andrianov <andrew@ncrmnt.org>