Fixes from https://github.com/Baystation12