Clean [for the most part] working code