A ton of cleaning up, but i think it all works now.