Andrey's fixes through part of API
Had to reconcile some changes with the recent commit, went through file-by-file to retain fixes in cases of conflicts.
Had to reconcile some changes with the recent commit, went through file-by-file to retain fixes in cases of conflicts.