Updated with changes from upstream