Updated to work with latest changes from master