Various fixes

Not going to make a separate PR for every commit because that would be unproductive overhead. But would definitely love if someone (i.e. Eddie) could review the changes.