latest changes from main fork ported