Actually there's a mistake in the way I wrote it, but the direction flags should be set here only, since we don't set it up anymore in the setup functions.