Fixing a bunch of issues in the process. --------- Co-authored-by: gbyl <gbyl@users.noreply.github.com>