Refactored more stuff into directive