Fixes all cast-related errors in <algorithm>.
Quick commit; I have to modify the template parameter storage mechanism.