Fixed some bugs handling tuples