major cleanup and simplification :)