Huge refactoring

- Reorganizing code for cleanup and extension

Signed-off-by: Dustin Ngo (laptop) <dustin.ngo@gmail.com>