Removes dead code and misc cleanup