refactored a butt-load of stuff