Fixes #4635

Fix for https://github.com/Baystation12/Baystation12/issues/4635 + some cleanup.