Cleaned the code. 

Added Functor implemenations