Huge refactor

Signed-off-by: Ramnique Singh <mail@ramniquesingh.name>