Pass dependencies to handlers

instead of fetching them from global variables.