Bug fixes found by @Sanctum32