Merged in changes from shell implementation