Massive overhaul

Made the damn thing to work too. It's ugly as hell but it works.