Moved functionality to hooks.