Added fixes from previous branch