Fix argument and directionality bugs